package MicroSpring.common;
/*
    符号解析工具
 */
public class SymbolResovler {

    /*
        解析${xx}
     */
    public static String getResovleStringFromResource(String symbol){
        int length = symbol.length();
        if (symbol.length()<=0)
            return null;
        if (symbol.charAt(0)!='$')
            return symbol;
        if (length <=3)
            return null;
        if (symbol.charAt(0)=='$' && symbol.charAt(1)=='{' && symbol.charAt(length-1)=='}') {
            String position = symbol.substring(2, length - 1);
            String value=null;
            value= ResourceValueReader.getValueByPropertiesKey(position);
            if (StringUtils.hasText(value))
                return value;
            value =ResourceValueReader.getValueByYmlKey(position);
            if (StringUtils.hasText(value))
                return value;
            value =ResourceValueReader.getValueByYamlKey(position);
            if (StringUtils.hasText(value))
                return value;

        }
        return null;
    }

}
